<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        function generator(arr) {
            var nextIndex = 0;
            return {
                next: () => {
                    if (nextIndex < arr.length) {
                        return { value: arr[nextIndex++], done: false }
                    } else {
                        return { done: true }
                    }
                }
            }
        }
        var arr = ["起床", "吃中饭", "睡觉"];
        var obj = generator(arr);
        console.log(obj.next())
        console.log(obj.next())
        console.log(obj.next())
        console.log(obj.next())
    </script>
</body>

</html>